<?php
	$apis = array(
			'test'=>array(
			'index'=>array('name'=>'','sex'=>''),
                                        
			),
			'companyProduct' => array(
                            'getProductList'=> array('companyid'=>'','num'=>'','page'=>'1'),
                            'getProductInfo'=> array('product_id'=>'')
                            ),
                        'companyOrder'=>array(
                            'confirmTradingSuccess'=>array('order_id'=>'')
                        ),
			'companyOrder'=>array(			
							'creatOrders'=>array('user_id'=>'','product_id'=>'','number'=>'','province'=>'','city'=>'','county'=>'','address'=>'','consignee'=>'','remarks'=>'','phone'=>''),
							'userNotpayOrder'=>array('user_id'=>'','num'=>'','page'=>'1'),
							'userOrderList'=>array('user_id'=>'','num'=>'','page'=>'1'),
							
							'addAddress'=>array('user_id'=>'','province'=>'','city'=>'','area'=>'','address'=>'','name'=>'','phone'=>'','tell'=>'','code'=>'','is_default'=>''),
								
							'AddressList'=>array('user_id'=>'','num'=>'','page'=>'1'),
							
							'editReceAddress'=>array('id'=>'','user_id'=>'','tell'=>'','name'=>'','code'=>'','phone'=>'','province'=>'','city'=>'','county'=>'','address'=>'','is_default'=>''),
							'delReceAddress'=>array('id'=>''),
							'setDefault'=>array('id'=>'','user_id'=>''),
								),
			'user'=>array(
					'getCode'=>array('phoneNumber'=>''),
					'login'=>array('phoneNumber'=>'','password'=>''),
					'forgotPassword'=>array('phoneNumber'=>'','password'=>'','repassword'=>''),
					'getregist'=>array('id'=>''),
					'additional'=>array('userName'=>'','sex'=>'','age'=>'','address'=>'','card'=>'','id'=>''),
					'userCenter'=>array('user_id'=>''),
		    		'investmentList'=>array('user_id'=>'','num'=>'10','page'=>'1'),
                        'investmentDeltail'=>array('investment_id'=>''),
					'accountBalance'=>array('user_id'=>''),
					'payToAccount'=>array('user_id'=>'','payMoney'=>''),
					'cashToAccount'=>array('user_id'=>'','cashMoney'=>''),
					'collect'=>array('userid'=>'','companyid'=>''),
					'collectList'=>array('user_id'=>'','num'=>'10','page'=>'1'),
					'sale'=>array('investment_id'=>''),
					'investment'=>array('user_id'=>'','company_id'=>'','money'=>'','date'=>'','value_date'=>''),
					'getCollectState'=>array('userid'=>'','companyid'=>''),
					'bankCardList'=>array('user_id'=>''),
                        'addBankCard'=>array('user_id'=>'','bank_name'=>'','card_no'=>'','IDName'=>'','IDCardNo'=>''),
					'getFeedBack'=>array('user_id'=>'','content'=>''),
					'getService'=>array(),
					'userReport'=>array('user_id'=>'','company_id'=>'','content'=>''),
					'getUserGroup'=>array('userId'=>''),
					'getUserReport'=>array('userid'=>''),
					'getUserReportDetail'=>array('userid'=>'','companyid'=>''),
					'getReport'=>array('id'=>''),
			),
			'register'=>array(
					'regist'=>array('phoneNumber'=>'','password'=>'','repassword'=>''),
			),
			'companys'=>array(
			        'share'=>array(),
			        'firstAdver'=>array(),
					'getCompanyInfo'=>array('company_id'=>'','num'=>'','page'=>'1'),
					'getCompanyList'=>array('num'=>'','page'=>'1'),
					'getCompanyDetail'=>array('companyid'=>'','num'=>'','page'=>''),
					'CompanyClick'=>array('userid'=>'','companyid'=>''),
					'getCompanyClick'=>array('companyid'=>''),
					'getClickState'=>array('userid'=>'','companyid'=>''),
					'strThird'=>array('catefrist'=>'','catesecond'=>'','num'=>'','page'=>'1'),
                                        'addSeeNum' =>array('userid'=>'','companyid'=>'')
	        ),
			'find'=>array(
					'channelList'=>array(),
					'informationList'=>array('channel_id'=>'','num'=>'','page'=>''),
					'informationDetail'=>array('information_id'=>''),
					'searchInformation'=>array('keywords'=>''),
					'searchMuch'=>array('num'=>'','page'=>'1','company_name'=>'','star'=>'','province'=>'','city'=>'','county'=>'','secondcate'=>'','firstcate'=>''),
			),
	        'classify'=>array(
					 'getFirst'=>array(),
					 'getSecond'=>array('id'=>''),
					 'getThird'=>array('id'=>'','num'=>'','page'=>'1'),
	        ),
	         'area'=>array(
	        		'citys'=>array(),
	        		'hot_city'=>array('num'=>''),
	        		'county_list'=>array('fid'=>''),
	        		'city_one'=>array('id'=>''),
	        ),


	      'bank'=>array(
	        		'banklogo'=>array(),
	        ),
			'RCServer'=>array(
	        	'getToken'=>array('userId'=>'','name'=>'','portraitUri'=>''),
	        	'groupCreate'=>array('userId'=>'','companyId'=>'','groupName'=>''),
	        	'groupUserQuery'=>array('groupId'=>''),
	        	'groupJoin'=>array('userId'=>'','groupId'=>''),
	        	'groupQuit'=>array('userId'=>'','groupId'=>'','users'=>''),
	        	'groupDismiss'=>array('userId'=>'','groupId'=>''),
			    'getCompanyGroup'=>array('companyId'=>'','userId'=>''),
				'exitGroup'=>array('user_id'=>'','group_id'=>''),
	       	),

	       	'alipay'=>array(
					'createSign'=>array('out_trade_no'=>date('Ymd').rand(1000,9999),'order_id'=>''),
					'backSign'=>array('batch_no'=>date('Ymd').rand(1000,9999),'order_id'=>'' , 'refund_cash' => '' , 'reason' => ''),
					'refundApply'=>array('order_id'=>'' , 'refund_cash' => '' , 'reason' => ''),
			),

			'wxpay'=>array(
					'createSign'=>array('order_id'=>'' , 'spbill_create_ip' => ''),
					
					'refundApply'=>array('order_id'=>'' , 'refund_cash' => '' , 'reason' => ''),
			),

	);
	if($_GET['action']=='getA'){
		echo json_encode($apis[$_POST['c']]);
		exit();
	}
	if($_GET['action']=='getJ'){
		echo ch_json_encode($apis[$_POST['c']][$_POST['a']]);
		exit();
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery.js"></script>
<script>
	$(function(){
		sign();
		$("select").change(function(){sign();})
		$("input").change(function(){sign();})
		$("textarea").change(function(){sign();})
		$("#timesnamp").click(function(){
			$("[name=timesnamp]").val(Date.parse(new Date())/1000);
			sign();
		})
		$("[name=c]").change(function(){
			var c = $(this).val();
			$.post(
				'test.php?action=getA',
				{c:c},
				function(data){
					var html = '<option value=""></option>';
					$.each(data,function(i){
						html += '<option value="'+i+'">'+i+'</option>';
					})
					$("[name=a]").html(html);
				}
				,'json'
			)
		})
		$("[name=a]").change(function(){
			var c = $("[name=c]").val();
			var a = $(this).val();
			$.post(
				'test.php?action=getJ',
				{c:c,a:a},
				function(data){
					$("[name=param]").val(data);
				}
			)
		})
	})
	
	function sign(){
		var name = $(this).attr("name");
		if(name!='sign'){
			var c = $("[name=c]").val();
			var a = $("[name=a]").val();
			var timesnamp = $("[name=timesnamp]").val();
			var openid = $("[name=openid]").val();
			$.post(
				'create_sign.php',
				{c:c,a:a,timesnamp:timesnamp,openid:openid},
				function(data){
					$("[name=sign]").val(data.sign);
				}
				,'json'
			)
		}
	}
</script>
</head>
<body>
	<form action="index.php" method="post" target="_blank">
		<p>
			c：
			<select name="c">
				<option value=""></option>
				<?foreach($apis as $k=>$v){?>
				<option value="<?=$k?>"><?=$k?></option>
				<?}?>
			</select>
		</p>
		<p>
			a：
			<select name="a"></select>
		</p>
		<p>
			param:
			<textarea name="param" cols="50" rows="5"></textarea>
		</p>
		<p>
			timesnamp： <input type="text" name="timesnamp" value="<?=time()?>" /> <input type="button" id="timesnamp" value="刷新" />
		</p>
		<p>
			openid： <input type="text" name="openid" value="1" />
		</p>
		<p>
			sign： <input type="text" name="sign" value="" size="40" />
		</p>
		<p>
			<input type="submit" value="提交" />
		</p>
	</form>
</body>
</html>
<?php
function ch_json_encode($data){
	/**
	 * 将中文编码
	 * 
	 * @param array $data        	
	 * @return string
	 */
	function ch_urlencode($data){
		if(is_array($data) || is_object($data)){
			foreach ($data as $k => $v) 
			{
				if(is_scalar($v)){
					if(is_array($data)){
						$data[$k] = urlencode($v);
					}elseif(is_object($data)){
						$data->$k = urlencode($v);
					}
				}elseif(is_array($data)){
					$data[$k] = ch_urlencode($v); // 递归调用该函数
				}elseif(is_object($data)){
					$data->$k = ch_urlencode($v);
				}
			}
		}
		return $data;
	}
	$ret = ch_urlencode($data);
	$ret =json_encode($ret);
	return urldecode($ret);
}
?>